package com.china_goldcard.igas.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by jk on 16/10/10.
 */
public class VersionUtils {

    /**
     * 取APP版本号
     * @return
     */
    public static int getAppVersionCode(Context application){
        try {
            PackageManager mPackageManager = application.getPackageManager();
            PackageInfo _info = mPackageManager.getPackageInfo(application.getPackageName(),0);
            return _info.versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            return 0;
        }
    }

    /**
     * 取APP版本名
     * @return
     */
    public static String getAppVersionName(Context application){
        try {
            PackageManager mPackageManager = application.getPackageManager();
            PackageInfo _info = mPackageManager.getPackageInfo(application.getPackageName(),0);
            return _info.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            return "";
        }
    }
}
